home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Sources / FWPrtIte.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  9.4 KB  |  315 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPrtIte.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWPRTITE_H
  13. #include "FWPrtIte.h"
  14. #endif
  15.  
  16. #ifndef FWFRAME_H
  17. #include "FWFrame.h"
  18. #endif
  19.  
  20. #ifndef FWFRMING_H
  21. #include "FWFrming.h"
  22. #endif
  23.  
  24. #ifndef FWITERS_H
  25. #include "FWIters.h"
  26. #endif
  27.  
  28. #ifndef FWPXYFRM_H
  29. #include "FWPxyFrm.h"
  30. #endif
  31.  
  32. // ----- ODUtil -----
  33.  
  34. #ifndef FWORDCOL_H
  35. #include "FWOrdCol.h"
  36. #endif
  37.  
  38. // ----- OpenDoc Includes -----
  39.  
  40. #ifndef SOM_ODFacetIterator_xh
  41. #include <FacetItr.xh>
  42. #endif
  43.  
  44. #ifndef SOM_ODFrameFacetIterator_xh
  45. #include <FrFaItr.xh>
  46. #endif
  47.  
  48. //========================================================================================
  49. //    Runtime informations
  50. //========================================================================================
  51.  
  52. #if FW_LIB_EXPORT_PRAGMAS
  53. #pragma lib_export on
  54. #endif
  55.  
  56. #ifdef FW_BUILD_MAC
  57. #pragma segment framework
  58. #endif
  59.  
  60. //========================================================================================
  61. //    class FW_CPartFrameIterator
  62. //========================================================================================
  63.  
  64. //---------------------------------------------------------------------------------------
  65. //    FW_CPartFrameIterator::FW_CPartFrameIterator
  66. //---------------------------------------------------------------------------------------
  67.  
  68. FW_CPartFrameIterator::FW_CPartFrameIterator(const FW_CPart* part) :
  69.     fPresentationIterator(NULL),
  70.     fFrameIterator(NULL),
  71.     fCurrentFrame(NULL)
  72. {
  73.     fPresentationIterator = FW_NEW(FW_CPartPresentationIterator, (part));
  74.     FW_END_CONSTRUCTOR
  75. }
  76.  
  77. //---------------------------------------------------------------------------------------
  78. //    FW_CPartFrameIterator::~FW_CPartFrameIterator
  79. //---------------------------------------------------------------------------------------
  80.  
  81. FW_CPartFrameIterator::~FW_CPartFrameIterator()
  82. {
  83.     FW_START_DESTRUCTOR
  84.     
  85.     delete fPresentationIterator;
  86.     fPresentationIterator = NULL;
  87.  
  88.     delete fFrameIterator;
  89.     fFrameIterator = NULL;
  90. }
  91.  
  92. //---------------------------------------------------------------------------------------
  93. //    FW_CPartFrameIterator::First
  94. //---------------------------------------------------------------------------------------
  95.  
  96. FW_CFrame* FW_CPartFrameIterator::First()
  97. {
  98.     FW_CPresentation* presentation = fPresentationIterator->First();
  99.     PrivFirstFrame(presentation);
  100.     
  101.     return fCurrentFrame;
  102. }
  103.  
  104. //---------------------------------------------------------------------------------------
  105. //    FW_CPartFrameIterator::Last
  106. //---------------------------------------------------------------------------------------
  107.  
  108. FW_CFrame* FW_CPartFrameIterator::Last()
  109. {
  110.     FW_CPresentation* presentation = fPresentationIterator->Last();
  111.     PrivLastFrame(presentation);
  112.  
  113.     return fCurrentFrame;
  114. }
  115.  
  116. //---------------------------------------------------------------------------------------
  117. //    FW_CPartFrameIterator::Next
  118. //---------------------------------------------------------------------------------------
  119.  
  120. FW_CFrame* FW_CPartFrameIterator::Next()
  121. {
  122.     FW_ASSERT(fFrameIterator);
  123.     
  124.     fCurrentFrame = fFrameIterator->Next();
  125.     if (fCurrentFrame == NULL)
  126.     {
  127.         FW_CPresentation* presentation = fPresentationIterator->Next();
  128.         PrivFirstFrame(presentation);
  129.     }
  130.         
  131.     return fCurrentFrame;
  132. }
  133.  
  134. //---------------------------------------------------------------------------------------
  135. //    FW_CPartFrameIterator::Previous
  136. //---------------------------------------------------------------------------------------
  137.  
  138. FW_CFrame* FW_CPartFrameIterator::Previous()
  139. {
  140.     FW_ASSERT(fFrameIterator);
  141.     
  142.     fCurrentFrame = fFrameIterator->Previous();
  143.     if (fCurrentFrame == NULL)
  144.     {
  145.         FW_CPresentation* presentation = fPresentationIterator->Previous();
  146.         PrivLastFrame(presentation);
  147.     }
  148.         
  149.     return fCurrentFrame;
  150. }
  151.  
  152. //---------------------------------------------------------------------------------------
  153. //    FW_CPartFrameIterator::PrivFirstFrame
  154. //---------------------------------------------------------------------------------------
  155.  
  156. void FW_CPartFrameIterator::PrivFirstFrame(FW_CPresentation* presentation)
  157. {
  158.     fCurrentFrame = NULL;
  159.     
  160.     delete fFrameIterator;
  161.     fFrameIterator = NULL;
  162.     
  163.     while (presentation != NULL)
  164.     {
  165.         fFrameIterator = FW_NEW(FW_CPresentationFrameIterator, (presentation));
  166.         fCurrentFrame = fFrameIterator->First();
  167.         if (fCurrentFrame != NULL)
  168.             return;
  169.         
  170.         delete fFrameIterator;
  171.         fFrameIterator = NULL;
  172.         presentation = fPresentationIterator->Next();            
  173.     }
  174. }
  175.  
  176. //---------------------------------------------------------------------------------------
  177. //    FW_CPartFrameIterator::PrivLastFrame
  178. //---------------------------------------------------------------------------------------
  179.  
  180. void FW_CPartFrameIterator::PrivLastFrame(FW_CPresentation* presentation)
  181. {
  182.     fCurrentFrame = NULL;
  183.     
  184.     delete fFrameIterator;
  185.     fFrameIterator = NULL;
  186.     
  187.     while (presentation != NULL)
  188.     {
  189.         fFrameIterator = FW_NEW(FW_CPresentationFrameIterator, (presentation));
  190.         fCurrentFrame = fFrameIterator->Last();
  191.         if (fCurrentFrame != NULL)
  192.             return;
  193.         
  194.         delete fFrameIterator;
  195.         fFrameIterator = NULL;
  196.         presentation = fPresentationIterator->Previous();            
  197.     }
  198. }
  199.  
  200. //========================================================================================
  201. //    class FW_CPartPresentationIterator
  202. //========================================================================================
  203.  
  204. //---------------------------------------------------------------------------------------
  205. //    FW_CPartPresentationIterator::FW_CPartPresentationIterator
  206. //---------------------------------------------------------------------------------------
  207.  
  208. FW_CPartPresentationIterator::FW_CPartPresentationIterator(const FW_CPart* part) :
  209.     fIterator(NULL)
  210. {
  211.     fIterator = new FW_COrderedCollectionIterator(part->fPresentations);
  212.     FW_END_CONSTRUCTOR
  213. }
  214.  
  215. //---------------------------------------------------------------------------------------
  216. //    FW_CPartPresentationIterator::~FW_CPartPresentationIterator
  217. //---------------------------------------------------------------------------------------
  218.  
  219. FW_CPartPresentationIterator::~FW_CPartPresentationIterator()
  220. {
  221.     FW_START_DESTRUCTOR
  222.     
  223.     delete fIterator;
  224.     fIterator = NULL;
  225. }
  226.  
  227. //========================================================================================
  228. //    FW_CPartProxyFrameIterator
  229. //========================================================================================
  230.  
  231. //----------------------------------------------------------------------------------------
  232. //    FW_CPartProxyFrameIterator::FW_CPartProxyFrameIterator
  233. //----------------------------------------------------------------------------------------
  234.  
  235. FW_CPartProxyFrameIterator::FW_CPartProxyFrameIterator(const FW_CEmbeddingPart* part):
  236.     fIterator(NULL)
  237. {
  238.     fIterator = new FW_COrderedCollectionIterator(part->fProxyFrames);
  239.     FW_END_CONSTRUCTOR
  240. }
  241.  
  242. //----------------------------------------------------------------------------------------
  243. //    FW_CProxyProxyFrameIterator::~FW_CProxyProxyFrameIterator
  244. //----------------------------------------------------------------------------------------
  245.  
  246. FW_CPartProxyFrameIterator::~FW_CPartProxyFrameIterator()
  247. {
  248.     FW_START_DESTRUCTOR
  249.     delete fIterator;
  250. }
  251.  
  252. //========================================================================================
  253. //    FW_CPartEmbeddedFrameIterator
  254. //========================================================================================
  255.  
  256. //----------------------------------------------------------------------------------------
  257. //    FW_CPartEmbeddedFrameIterator::FW_CPartEmbeddedFrameIterator
  258. //----------------------------------------------------------------------------------------
  259.  
  260. FW_CPartEmbeddedFrameIterator::FW_CPartEmbeddedFrameIterator(Environment* ev, const FW_CEmbeddingPart* part, FW_CEmbeddingFrame* frame) :
  261.     fIterator(part),
  262.     fCurrentFrame(NULL)
  263. {
  264.     FW_END_CONSTRUCTOR
  265. }
  266.  
  267. //----------------------------------------------------------------------------------------
  268. //    FW_CPartEmbeddedFrameIterator::~FW_CPartEmbeddedFrameIterator
  269. //----------------------------------------------------------------------------------------
  270.  
  271. FW_CPartEmbeddedFrameIterator::~FW_CPartEmbeddedFrameIterator()
  272. {
  273.     FW_START_DESTRUCTOR
  274. }
  275.  
  276. //----------------------------------------------------------------------------------------
  277. //    FW_CPartEmbeddedFrameIterator::First
  278. //----------------------------------------------------------------------------------------
  279.  
  280. ODFrame* FW_CPartEmbeddedFrameIterator::First(Environment* ev)
  281. {
  282.     FW_CProxyFrame* proxyFrame = fIterator.First();
  283.     fCurrentFrame = PrivNext(ev, proxyFrame);
  284.     return fCurrentFrame;
  285. }
  286.  
  287. //----------------------------------------------------------------------------------------
  288. //    FW_CPartEmbeddedFrameIterator::Next
  289. //----------------------------------------------------------------------------------------
  290.  
  291. ODFrame* FW_CPartEmbeddedFrameIterator::Next(Environment* ev)
  292. {
  293.     FW_CProxyFrame* proxyFrame = fIterator.Next();
  294.     fCurrentFrame = PrivNext(ev, proxyFrame);
  295.     return fCurrentFrame;
  296. }
  297.  
  298. //----------------------------------------------------------------------------------------
  299. //    FW_CPartEmbeddedFrameIterator::PrivNext
  300. //----------------------------------------------------------------------------------------
  301.  
  302. ODFrame* FW_CPartEmbeddedFrameIterator::PrivNext(Environment* ev, FW_CProxyFrame* proxyFrame)
  303. {
  304.     while (proxyFrame != NULL)
  305.     {
  306.         if (proxyFrame->IsFrameInMemory(ev))
  307.             return proxyFrame->GetFrame(ev);
  308.         
  309.         proxyFrame = fIterator.Next();
  310.     }
  311.     
  312.     return NULL;
  313. }
  314.  
  315.